import React, { Component } from 'react'
import { View, StyleSheet, Image } from 'react-native'
import CustomButton from '../button/CustomButton'

export default class CustomCheckBox extends Component {
  constructor (props) {
    super(props)
    this.state = {
      isCheck: props.defaultCheck
    }
  }

  render () {
    return (
      <View style={styles.container}>
        <CustomButton onPress={this.onCheckChange}>
          <Image
            style={styles.check}
            source={this.state.isCheck ? require('../../imgC/protocol_check.png') : require('../../imgC/protocol_uncheck.png')}/>
        </CustomButton>
      </View>
    )
  }

  onCheckChange () {
    const isCheck = !this.state.isCheck
    this.setState({
      isCheck
    })
    this.props.onCheckChange && this.props.onCheckChange(isCheck)
  }
}

const styles = StyleSheet.create({
  container: {},
  check: {
    width: 20,
    height: 20,
    marginRight: 5
  }
})
